-
-
Notifications
You must be signed in to change notification settings - Fork 16.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new --vid-stride
inference parameter for videos
#9256
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👋 Hello @VELCpro, thank you for submitting a YOLOv5 🚀 PR! To allow your work to be integrated as seamlessly as possible, we advise you to:
- ✅ Verify your PR is up-to-date with
ultralytics/yolov5
master
branch. If your PR is behind you can update your code by clicking the 'Update branch' button or by runninggit pull
andgit merge master
locally. - ✅ Verify all YOLOv5 Continuous Integration (CI) checks are passing.
- ✅ Reduce changes to the absolute minimum required for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee
@VELCpro thanks for the PR! The code additions are too complicated to be added to master, especially the multiple units, but there is an example in LoadStreams with a single variable called A couple things to remember here are that detect.py and classify/predict.py would both need to be updated, and that LoadStreams and LoadImages should share common arguments and funcitonalities, so if we exposed a new variable at the argparser it should affect both identically, i.e. Lines 377 to 383 in 9da6d0f
|
@glenn-jocher thanks for the feedback! |
869c010
to
5288688
Compare
5288688
to
5f59213
Compare
for more information, see https://pre-commit.ci
Signed-off-by: Glenn Jocher <[email protected]>
@VELCpro thanks for the updates, this looks a lot simpler now! Is this ready to merge? Have you tested on videos? |
@glenn-jocher yes I tested on videos and on a folder with multiple videos and seems ok. I didn't test the piece of code about rtsp stream but seems trivial. The change only added a variable, the logic behind is untouched |
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
Signed-off-by: Glenn Jocher <[email protected]>
@VELCpro looks good now. The only issue I see is that the default naming and value make it seem like we are skipping every 1 frame, i.e. defaulting to 15 FPS. Not sure if there's a better wording here like vid_stride or something. What do you think? |
@glenn-jocher yes actually naming the variable skip_frame could cause some confusion. vid_stride seems ok to me |
@VELCpro perfect. I'll update. |
--vid-stride
inference parameter for videos
@VELCpro PR is merged. Thank you for your contributions to YOLOv5 🚀 and Vision AI ⭐ |
@glenn-jocher happy to help 🙂 |
* fps feature/skip frame added * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * predict.py updates * Update dataloaders.py Signed-off-by: Glenn Jocher <[email protected]> * Update dataloaders.py Signed-off-by: Glenn Jocher <[email protected]> * remove unused attribute Signed-off-by: Glenn Jocher <[email protected]> * Cleanup Signed-off-by: Glenn Jocher <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update predict.py Signed-off-by: Glenn Jocher <[email protected]> * Update detect.py Signed-off-by: Glenn Jocher <[email protected]> * Update dataloaders.py Signed-off-by: Glenn Jocher <[email protected]> * Rename skip_frame to vid_stride * cleanup * cleanup2 Signed-off-by: Glenn Jocher <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Glenn Jocher <[email protected]>
@VELCpro @glenn-jocher Hello, hope you are doing well. I have trained a custom model on yolov8n which will detect the night traffic. I have to use it on 8 streams (or 4 in worst case) but I am facing too much lag. And when I use vid_stride, it skips the frames but the stream is still very slow. Is there a way to get better fps for that much streams using yolov8n? |
Hi @Mohammad-Saad-eng everything good thank you for asking. As you notice the vid_stride parameter allows to skip frames during the detection over a video. Other ways to improve latency without touching the actual models are for example to reduce the input size of the frames given to the model for the detection. Clearly it's a matter of trade-offs between latency and accuracy. What hardware you are testing the model on? |
@VELCpro I am also fine. I have tested it on Jetson Nano so far. Jetson is currently using DeepStream and TrafficCamNet for 8 streams. As number of parameters in yolov8n is significantly smaller than TrafficCamNet, I figured yolo would work fine too. |
Me and my team are currently using a Jetson orin 32GB in conjunction with yolov8n to perform object tracking obtaining good results both in terms of accuracy and fps. The Jetson Nano should be capable of running yolov5n (despite the limited power and the different architecture in respect to yolov8n) Here you can find an fps benchmark analysis performed by seeed studio where yolov5n6 run FP16 inferences in 48ms on a Jetson Nano. I think also they used directly the yolo docker container without deepstream. Hope it helps |
Hi @VELCpro-eng, We have successfully used a Jetson Orin 32GB with yolov8n for object tracking, achieving good results in terms of both accuracy and FPS. Although the Jetson Nano has limited power and a different architecture compared to yolov8n, it should still be capable of running yolov5n. Seeed Studio has performed an FPS benchmark analysis, running yolov5n6 in FP16 inferences in 48ms on a Jetson Nano. You can find the analysis here. In addition to using the I hope these suggestions help. |
@glenn-jocher as seen in the issue #8079 (comment) there's the need sometimes to skip frames while performing inference on a video.
One of the useful use cases could be batch processing of very long archive videos where high frame rates are not needed.
I added two parameters to detect.py
Where :
example use:
python detect.py --device 0 --weights yolov5s.pt --inf-rate 1 --fr-unit fps --source vid.mp4
🛠️ PR Summary
Made with ❤️ by Ultralytics Actions
🌟 Summary
Enhancement to video frame processing with the introduction of frame-rate stride control.
📊 Key Changes
vid_stride
parameter to control the stride of video frame processing (skipping frames).vid_stride
is implemented inLoadImages
andLoadStreams
classes, affecting how videos are loaded and processed.vid_stride
option is added as a command-line argument in bothpredict.py
anddetect.py
scripts, permitting customization from the command-line interface.🎯 Purpose & Impact